import type { IModalConfig } from '@/global/types'

export const modalEditConfig: IModalConfig = {
  type: 'drawer',
  layout: {
    title: '编辑用户',
    size: '35%',
    showClose: true, // 是否显示右上角关闭图标
    closeOnClickModal: true // 点击遮罩层是否能关闭对话框
  },
  form: {
    layout: {
      isShowBtns: false,
      labelWidth: '80px',
      size: 'default'
    },
    items: [
      {
        type: 'img',
        prop: 'headPortrait',
        span: 24,
        label: '头像'
      },
      {
        type: 'input',
        prop: 'userName',
        span: 24,
        label: '用户名',
        placeholder: '请输入用户名'
      },
      {
        type: 'input',
        prop: 'nickName',
        span: 24,
        label: '昵称',
        placeholder: '请输入昵称'
      },
      {
        type: 'input',
        prop: 'userPhone',
        span: 24,
        label: '手机号',
        placeholder: '请输入手机号'
      },
      {
        type: 'input',
        prop: 'identityCard',
        span: 24,
        label: '身份证',
        placeholder: '请输入身份证'
      },
      {
        type: 'select',
        prop: 'sex',
        span: 24,
        label: '性别',
        placeholder: '请选择性别',
        options: [
          { label: '男', value: 1 },
          { label: '女', value: 0 }
        ]
      },
      {
        type: 'custom',
        slotName: 'uploadImage',
        span: 24
      }
    ],
    rules: {
      userPhone: [
        {
          message: '请输入有效的手机号',
          pattern:
            /^(0|86|17951)?(13[0-9]|15[012356789]|166|17[3678]|18[0-9]|14[57])[0-9]{8}$/,
          trigger: 'blur'
        }
      ],
      identityCard: [
        {
          message: '请输入有效的身份证',
          pattern: /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/,
          trigger: 'blur'
        }
      ]
    }
  }
}

export default modalEditConfig
